import Vue from 'vue'
import Vuex from 'vuex'
import { orderList } from '@/api/order'

// import configData from './module/config'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    orderList: [],
    storeMenuCurrent: sessionStorage.getItem('menuCurrent')
      ? sessionStorage.getItem('menuCurrent')
      : '/',
    leftActive: '',
    leftOpenName: [],
    market: [],
    nav: [],
    updataOrder: [],
    storeId: sessionStorage.getItem('storeId')
      ? sessionStorage.getItem('storeId')
      : '',
    storeData: {},
    jurisdiction: {}
  },
  mutations: {
    getjurisdiction (state, data) {
      state.jurisdiction = data
    },
    setOrderList (state, data) {
      //订单列表
      state.orderList = data
    },
    setmenuCurrent (state, data) {
      //当前菜单选择效果
      state.storeMenuCurrent = data
    },
    setleftActive (state, data) {
      //左侧菜单选择效果
      state.leftActive = data
    },
    setleftOpenName (state, data) {
      //菜单展开效果索引
      state.leftOpenName = data
    },
    //查询商家
    searchMarket (state, data) {
      state.market = data
    },
    //更新订数据
    updataOrderNumber (state, data) {
      state.updataOrder = data
    },
    //页面菜单数据
    menuNav (state, data) {
      state.nav = data
    },
    storeMsg (state, data) {
      state.storeId = data
    },
    storeDataMutations (state, data) {
      state.storeData = data
    }
  },
  actions: {
    //订单列表
    async getStoreOrderList ({ commit, state }, params) {
      const data = await orderList(params)
      data && commit('setOrderList', data)
    },
    clickStoreMenuCurrent ({ commit, state }, params) {
      params && commit('setmenuCurrent', params)
    },
    clickStoreMleftActive ({ commit, state }, params) {
      params && commit('setleftActive', params)
    },
    clickStoreleftOpenName ({ commit, state }, params) {
      params && commit('setleftOpenName', params)
    }
  },
  modules: {
    // configData
  }
})
